package com.example.shop.common.dto.mail;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.Date;

@Data
@NoArgsConstructor
@Accessors(chain = true)
public class Mail {
    // 这个必须和你项目绑定的邮箱服务器里的授权码所归属的邮箱一致
    private static final String from = "electricity-shop@qq.com";
    //要求只能指定qq邮箱
    private String to;
    private String subject;
    private String content;
    //发送邮件的日期
    private Date date;

    public Mail(String to,String subject,String content){
        this.to = to;
        this.subject = subject;
        this.content = content;
        this.date = new Date();
    }

    /**
     * 校验to邮箱是否是qq邮箱
     * @return
     */
    public boolean isQQMail(){
        return to.matches("^\\D{5,12}@qq.com");
    }
    public String getFrom(){
        return from;
    }
}
